{template 'common/header'}
<ul class="nav nav-tabs">
	<li{if $do == 'display' && $t == 'news'} class="active"{/if}><a href="{php echo url('platform/resource', array('t' => 'news'))}">图文</a></li>
	<li{if $do == 'display' && $t == 'image'} class="active"{/if}><a href="{php echo url('platform/resource', array('t' => 'image'))}">图片</a></li>
	<li{if $do == 'display' && $t == 'voice'} class="active"{/if}><a href="{php echo url('platform/resource', array('t' => 'voice'))}">语音</a></li>
	<li{if $do == 'display' && $t == 'music'} class="active"{/if}><a href="{php echo url('platform/resource', array('t' => 'music'))}">音乐</a></li>
	<li{if $do == 'display' && $t == 'video'} class="active"{/if}><a href="{php echo url('platform/resource', array('t' => 'video'))}">视频</a></li>
</ul>
{if $do == 'display'}
<div class="main">
	<div class="search">
		<form action="platform.php" method="get">
		<input type="hidden" name="act" value="{$_GPC['act']}" />
		<input type="hidden" name="eid" value="{$_GPC['eid']}" />
		<input type="hidden" name="name" value="{$_GPC['name']}" />
		<input type="hidden" name="do" value="{$_GPC['do']}" />
		<input type="hidden" name="weid" value="{$_GPC['weid']}" />
		<table class="table table-bordered tb">
			<tbody>
				<tr>
					<th>素材类型</th>
					<td>
						<label class="checkbox inline">
							<input name="types[]" type="checkbox" value="image" {if in_array('image', $types)}checked="checked"{/if} > 图片
						</label>
						<label class="checkbox inline">
							<input name="types[]" type="checkbox" value="voice" {if in_array('voice', $types)}checked="checked"{/if}> 音频
						</label>
						<label class="checkbox inline">
							<input name="types[]" type="checkbox" value="video" {if in_array('video', $types)}checked="checked"{/if}> 视频
						</label>
					</td>
				</tr>
				 <tr class="search-submit">
					<td colspan="2"><button class="btn pull-right span2"><i class="icon-search icon-large"></i> 搜索</button></td>
				 </tr>
			</tbody>
		</table>
		</form>
	</div>
	<div style="padding:15px;">
		<h4>上传的媒体列表</h4>
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th>ID</th>
					<th>媒体</th>
					<th>类型</th>
					<th>缩略图</th>
					<th>上传时间</th>
					<th>过期时间</th>
				</tr>
			</thead>
			{loop $list $m}
			<thead>
				<tr>
					<td>{$m['mid']}</td>
					<td>
						<img src="http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$token}&media_id={$m['media_id']}" width="32" height="32">
					</td>
					<td>{$m['type']}</td>
					<td>
						{if !empty($m['thumb'])}
						<img src="http://file.api.weixin.qq.com/cgi-bin/media/get?access_token={$token}&media_id={$m['thumb']['media_id']}" width="32" height="32">
						{/if}
					</td>
					<td>{php echo date('Y-m-d h:i:s',$m['dateline'])}</td>
					<td>{php echo date('Y-m-d h:i:s',$m['dateline']+86400*3)}</td>
				</tr>
			</thead>
			{/loop}
		</table>
		{$pager}
	</div>

</div>
{/if}

{if $do == 'upload'}
<div class="main">
<form action="site.php" name="form" class="form-horizontal form" method="post" enctype="multipart/form-data">
	<h4>上传新素材</h4>
	<img src="http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=NyfWNn4aHfrau3zGcknMtriDXmMsMXLeSlQOVIrmR7rwE7fuHTH_rmv021RcnNY9w1rn5xUeu4HrC8w2cOdargb--_ZLXgvdL0OrndfWkNHj-HQuXhSHD7-pgJZOvDGZYFRlxRBrYdkZl4vJxhZy0w&media_id=E7ZMjvmT_HloVF_M2cj7b0vXdhZhD2lk5D4cU7bnbXmvaKPJOYktfAcC2tX-p4qR" >
	<div class="alert alert-block alert-new" id="cardmain">
		<table>
			<tr>
				<th><label for="">媒体类型</label></th>
				<td>
					<select id="uploadtype" name="type" method="GET" class="form-control">
						<option value="image">image</option>
						<option value="voice">voice</option>
						<option value="video">video</option>
					</select>
				</td>
			</tr>
			<tr>
				<th><label for="">媒体文件</label></th>
				<td>
					<input type="file" name="media" class="form-control">
				</td>
			</tr>
			<tr id="thumb" style="display:none;">
				<th><label for="">缩略图</label></th>
				<td>
					{php echo tpl_form_field_image('thumb','');}
				</td>
			</tr>
			<tr>
				<th><label for=""></label></th>
				<td>
					<button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
					<input type="hidden" name="token" value="{$_W['token']}" />
					<input type="hidden" name="act" value="module" />
					<input type="hidden" name="name" value="broadcast" />
					<input type="hidden" name="foo" value="upload" />
					<input type="hidden" name="do" value="media" />
				</td>
			</tr>
		</table>
	</div>
</form>
</div>



<script>
	$(function(){
		$('#uploadtype').change(function(){
			var val = $(this).val();
			if(val == 'voice' || val == 'video'){
				$('#thumb').show();
			} else {
				$('#thumb').hide();
			}
		});
	});
</script>

{/if}
{template 'common/footer'}